//Tue Jul 26 18:17:31 IST 2011

#include <stdio.h>
#include <string.h>

int main()
{
	char string[]= "abc", str[1000], dup[1000];

	int rotator, i, j, counter = 0;

	char t;

	for (rotator = 0; string[rotator]; rotator++) {
		strcpy (str, string);
		t = str[0];
		str[0] = str[rotator];
		str[rotator] = t;
		for (i=0; str[i]; i++) {
			strcpy(dup, str);
			for (j=0; str[j]; j++) {
				if (i != j) {
					t = dup[j];
					dup[j] = dup[i];
					dup[i] = t;
				}
				printf ("%d: %s\n", counter++, dup);
			}
		}
	}

	return 0;
}
//Tue Jul 26 19:04:53 IST 2011 - Unfair. As I was out most of the time. It took around 15 mins, still bad though.
